package com.purong.purong.activity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.purong.purong.R;
import com.purong.purong.bean.BankBean;
import com.purong.purong.widget.RadiusImageView;
import com.yao.sdk.glide.GlideUtil;

/**
 * Created by wenjiezeng on 2017/9/29.
 */
public class BankDetialActivity extends BaseActivity{
    private BankBean mBank;
    private RadiusImageView bankImg;
    private TextView bankName,bankOutLine,throughRate,ratifyVel,general,gold,
            platinum, heat,specially;

    @Override
    public void initBundle() {
        mBank=(BankBean)getIntent().getSerializableExtra("BANK");
    }

    @Override
    public int getRootViewId() {
        return R.layout.activity_bank_detial;
    }

    public void initView(){
        showBack();
        showTitle("银行详情");
        bankImg=(RadiusImageView)findViewById(R.id.bank_img);
        bankName=(TextView)findViewById(R.id.bank_name);
        bankOutLine=(TextView)findViewById(R.id.bank_outline);
        throughRate=(TextView)findViewById(R.id.through_rate);
        ratifyVel=(TextView)findViewById(R.id.ratify_velocity);
        general=(TextView)findViewById(R.id.general);
        gold=(TextView)findViewById(R.id.gold);
        platinum=(TextView)findViewById(R.id.platinum);
        heat=(TextView)findViewById(R.id.heat);
        specially=(TextView)findViewById(R.id.specially);
        switch (Integer.valueOf(mBank.getBank_id())%4){
            case 0:
                findViewById(R.id.bank_info_lay).setBackgroundResource(R.drawable.gradient_blue);
                break;
            case 1:
                findViewById(R.id.bank_info_lay).setBackgroundResource(R.drawable.gradient_purple);
                break;
            case 2:
                findViewById(R.id.bank_info_lay).setBackgroundResource(R.drawable.gradient_green);
                break;
            case 3:
                findViewById(R.id.bank_info_lay).setBackgroundResource(R.drawable.gradient_red);
                break;
        }
    }

    @Override
    public void initData() {
        setData();
    }

    private void setData(){
        if (mBank==null)
            return;
        GlideUtil.getInstance().load(this,mBank.getBank_url(),bankImg,true);
        bankName.setText(mBank.getBank_name());
        bankOutLine.setText(mBank.getBank_outline());
        throughRate.setText(mBank.getThrough_rate());
        ratifyVel.setText(mBank.getRatify_velocity());
        general.setText(mBank.getGeneral());
        gold.setText(mBank.getGold());
        platinum.setText(mBank.getPlatinum());
        heat.setText(mBank.getHeat());
        specially.setText(mBank.getSpecially());
    }
    private void call(String phone) {
        Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:"+phone));
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
    }
    public void onClick(View v){
        switch (v.getId()){
            case R.id.area_info:
                Intent intent=new Intent(this,BankWebSiteActivity.class);
                intent.putExtra("BANK_ID",mBank.getBank_id());
                startActivity(intent);
                break;
            case R.id.specially_lay:
                call(mBank.getSpecially());
                break;
            case R.id.heat_lay:
                call(mBank.getHeat());
                break;
        }
    }
}
